#include "PipeMessage.h"




PipeMessage::PipeMessage( MessageType _type )
	:mType(_type), mBufferChanged(true), mBuffer(NULL)
{

}


PipeMessage::~PipeMessage(void)
{
}

void PipeMessage::UpdateBuffer()
{
	delete [] mBuffer;
	UINT buffSize = GetBufferSize() + sizeof(MessageType);

	mBuffer = new BYTE[buffSize];
	memcpy_s(mBuffer, sizeof(MessageType), &mType, sizeof(MessageType));
	CreateBuffer(sizeof(MessageType));
	mBufferChanged = false;
}

BYTE* PipeMessage::Buffer( void )
{
	if( mBufferChanged)
		UpdateBuffer();

	return mBuffer;
}

UINT PipeMessage::GetSize()
{
	return sizeof(MessageType) + GetBufferSize();
}
